// ========================================================
// Des：
// Autor：Mr.H 
// CreateTime：2024/04/06 22:33:27
// 版 本：v 1.0
// ========================================================
using UnityEngine;

public class WeaponReward : MonoBehaviour
{
    public GameObject[] weapons;//武器预制体

    public GameObject getEff;//拾取特效
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            //玩家切换武器  随机切换
            int index = Random.Range(0, weapons.Length);
            //weapons[index]
            PlayerObj player = other.GetComponent<PlayerObj>();
            player.ChangeWeapon(weapons[index]);

            GameObject eff = Instantiate(getEff, transform.position,Quaternion.identity);
            AudioSource a = eff.GetComponent<AudioSource>();
            a.volume = GameDataMgr.Instance.musicData.soundValue;
            a.mute = !GameDataMgr.Instance.musicData.isOpenSound;

            Destroy(gameObject);
        }
    }
}
